package com.hspedu.tankgame04;

public class Tank {
    private int x;
    private int y;
    private int direct; //坦克方向
    private int speed = 5;
    boolean isLive = true;

    public Tank(int x, int y) {
        this.x = x;
        this.y = y;
    }

    //创建子弹
    public Shot createShot(){
        Shot shot = null;
        switch (this.direct){ //Hero的方向
            case 0:
                shot = new Shot(getX()+20, getY(), 0);
                break;
            case 1:
                shot = new Shot(getX()+60, getY()+20, 1);
                break;
            case 2:
                shot = new Shot(getX()+20, getY()+60, 2);
                break;
            case 3:
                shot = new Shot(getX(), getY()+20, 3);
                break;
        }
        return shot;
    }

    //移动方法
    public void moveUp() {
        if (y > 0) {
            y -= speed;
        }
    }
    public void moveRight() {
        if (x+60 < 1000) {
            x += speed;
        }
    }
    public void moveDown() {
        if (y+60 < 750){
            y += speed;
        }
    }
    public void moveLeft() {
        if (x > 0){
            x -= speed;
        }
    }


    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getDirect() {
        return direct;
    }

    public void setDirect(int direct) {
        this.direct = direct;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}
